﻿using MediatR;
using SY.BasicData.Api.Write.Basic.Applications.Cultivation.Command;
using SY.BasicData.Api.Write.Dto;
using SY.BasicData.Domain.Cultivation;
using SY.BasicData.Domain;
using SY.BasicData.ErrorCode;
using SY.BasicData.Infrastructures;

namespace SY.BasicData.Api.Write.Basic.Applications.Cultivation.CommandHandler
{
    public class GetPicQueryCommandHandler : IRequestHandler<GetPicQueryCommand, ApiResult<PictureModel>>
    {
        private readonly IBaseRepository<PictureModel> PictureRepository;
        private readonly IBaseRepository<CultivationModel> cultivationRepository;

        public GetPicQueryCommandHandler(IBaseRepository<PictureModel> pictureRepository, IBaseRepository<CultivationModel> cultivationRepository)
        {
            PictureRepository = pictureRepository;
            this.cultivationRepository = cultivationRepository;
        }
        public Task<ApiResult<PictureModel>> Handle(GetPicQueryCommand request, CancellationToken cancellationToken)
        {
            ApiResult<PictureModel> result = new ApiResult<PictureModel>();
            result.Code = ApiEnum.Success;
            result.Message = "图片反填成功";
            var list = PictureRepository.GetAll().Where(x => x.Batch == request.Batch).FirstOrDefault();
            result.Data = list;
            return Task.FromResult(result);
            
        }
    }
}
